let k = 123456
let result = 0
let b
for(let p=1; p<=10; p++)
    {
        b = k%10
        k = Math.floor(k/10)
        result += b
    }
    console.log(result)


//或者

let m = 123456
let result2 = 0
let n
while(m > 0)
    {
        n = m%10
        m = Math.floor(m/10)
        result2 += n
    }
    console.log(result2)
